package com.fzj.charging.device.controller;


import com.fzj.charging.common.pojo.JsonResult;
import com.fzj.charging.common.pojo.param.GunStatusUpdateParam;
import com.fzj.charging.common.pojo.vo.StationInfoVO;
import com.fzj.charging.device.pojo.dto.ChargingStationGetParam;
import com.fzj.charging.device.pojo.entity.ChargingStation;
import com.fzj.charging.device.pojo.vo.ChargingStationVO;
import com.fzj.charging.device.service.DeviceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RequestMapping("/device")
@RestController
@Slf4j
@Api(tags = "设备接口")
public class DeviceController {
    @Autowired
    private DeviceService deviceService;

    @GetMapping("station/info/{gunId}")
    @ApiOperation("获取场站信息")
    public JsonResult<StationInfoVO> getStationInfo(@PathVariable Integer gunId){
        log.debug("获取场站信息，参数：{}",gunId);
        StationInfoVO stationInfoVO = deviceService.getStationInfoVO(gunId);
        return JsonResult.ok(stationInfoVO,"获取场站信息成功");

    }
    @PostMapping("station/gun/status/update")
    @ApiOperation("修改枪的状态")
    public JsonResult<Boolean> updateGunStatus(@RequestBody GunStatusUpdateParam gunStatusUpdateParam){
        log.debug("修改枪的状态，参数：{}",gunStatusUpdateParam);
        Boolean gunStatusUpdateFlag = deviceService.updateGunStatus(gunStatusUpdateParam);
        return JsonResult.ok(gunStatusUpdateFlag,"枪状态修改成功");

    }
    @GetMapping("/station/circle")
    @ApiOperation("查询附近充电站")
    public JsonResult<List<ChargingStationVO>> getStationCircle(ChargingStationGetParam chargingStationGetParam){
        log.debug("查询附近充电站，参数：{}",chargingStationGetParam);
        List<ChargingStationVO> stationListByCircle = deviceService.getStationListByCircle(chargingStationGetParam);
        log.debug("查询附近充电站，参数：{},结果：{}",chargingStationGetParam,stationListByCircle);
        return JsonResult.ok(stationListByCircle,"查询附近充电站成功");
    }


}
